<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class="app-container">
    <el-form id="mvcfm">
      <el-row>
        <el-col :span="7" :xs="24">
          <div class="form-unit">
            <span class="mvc-title-left"> 我的仪表盘 </span>
          </div>
          <div>
          </div>
          <el-tree :data="s_firm" :highlight-current="true" class='mvctree' v-loading="treeloading" @node-click="handleNodeClick">
            <span class="el-tree-node__label" slot-scope="{node,data}" v-html="data.__desc"></span>
          </el-tree>
        </el-col>
        <el-col :span="16" :xs="24">
          <div class="form-unit">
            <a v-for="dict in s_outline" @click="handleNodeClick(dict)" type='primary'>{{dict.__desc}}></a>
          </div>
          <div class="el-select">
            <el-input v-model="s_search.name" placeholder='名称' />
          </div>
          <el-button @click="getPage(1);" type='primary' size="mini"><i class='fa fa-search'></i>搜索</el-button>
          <el-button @click="gotoPage('/oa/humanresources/StationAdd?'+vueparams+'')" type='success' size="mini"><i class='fa fa-plus'></i>增加一个岗位</el-button>
          <div>
          </div>
          <el-table :data="pageList" v-loading="loading">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_role('&CMID='+scope.row.role_id+'')">删除</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="gotoPage('/oa/humanresources/StationUp?CMID='+scope.row.role_id+''+vueparams+'')">修改</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="popStaffStaionMove('&CMID='+scope.row.role_id+'')">转移岗位人员</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="岗位名称" prop="role_id">
              <template slot-scope="scope">
                <el-link @click="gotoPage('/oa/humanresources/StationDet?CMID='+scope.row.role_id+''+vueparams+'')" type='primary'>{{scope.row.role}}</el-link>
              </template>
            </el-table-column>
            <el-table-column label="岗位类型" prop="station_type1">
            </el-table-column>
            <el-table-column label="工资核算方式" prop="role_wages1">
            </el-table-column>
          </el-table>
        </el-col>
      </el-row>
    </el-form>
    <el-dialog :visible.sync="StaffStaionMoveVisible" append-to-body>
      <StaffStaionMove v-if="StaffStaionMoveVisible" ref="StaffStaionMove" :popparams="popparams"> </StaffStaionMove>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import StaffStaionMove from "@/views/oa/humanresources/StaffStaionMove";
  export default {
    name: 'StaionAdmin',
    components: {
      StaffStaionMove,
    },
    props: ['popparams'],
    data() {
      return {
        StaffStaionMoveVisible: false,
        StaffStaionMoveValue: null,
        StaffStaionMoveDesc: null,
        vueparams: this.getVUEParams(""),
        s_search: {
          CMID1: null,
          name: null,
        },
        s_role: [],
        treeloading: true,
        s_firm: [],
        s_outline: [],
        loading: true,
        pageList: [],
        pageSize: 10,
        total: null,
        rules: {}
      }
    },
    created() {
      this.getData();
      this.getPage(1);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/oa/humanresources/StationAction/staionAdmin?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
          this["s_firm"] = this.loadTreeTable(this["s_firm"], "firm_id", "firm_higher");
          this.treeloading = false;
        })
      },
      d_role(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/oa/humanresources/StationAction/d_role?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      getPage(page) {
        this.loading = true;
        this.s_search.pageNo = page.page || page;
        this.s_search.pageSize = page.limit || 10;
        request({
          method: 'get',
          url: '/xcapi/VUEAction/oa/humanresources/StationAction/s_role?' + this.vueparams,
          params: this.s_search
        }).then(data => {
          this.loading = false;
          this.pageList = data.rows;
          this.total = data.total;
        })
      },
      popStaffStaionMove(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.StaffStaionMoveVisible = !this.StaffStaionMoveVisible;
      },
      handleNodeClick(data) {
        this.s_search.CMID1 = data.firm_id;
        this.handleOutline(data);
        this.getPage(1);
      },
      handleOutline(data) {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/oa/humanresources/StationAction/s_outline?' + this.vueparams,
          params: this.s_search
        }).then(data => {
          this.s_outline = data.s_outline;
          this.s_outline = this.s_outline.reverse();
        })
      },
    },
  }
</script>
